package com.example.managedbeans;
/**
 * DepartmentEntityHandlerBean.java
 * 
 */





import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;


import com.example.entities.*;
import com.example.service.*;





public class DepartmentEntityHandlerBean
{
  private String departmentName;
  private String departmentCity;
  private String departmentPhoneNumber;
  private  List<Department> departmentList;


public DepartmentEntityHandlerBean()
{
	
}
    	
	public List<Department> getDepartmentList() {
	return departmentList;
}

	public String getDepartmentName() {
	return departmentName;
}

public void setDepartmentName(String departmentName) {
	this.departmentName = departmentName;
}

public String getDepartmentCity() {
	return departmentCity;
}

public void setDepartmentCity(String departmentCity) {
	this.departmentCity = departmentCity;
}

public String getDepartmentPhoneNumber() {
	return departmentPhoneNumber;
}

public void setDepartmentPhoneNumber(String departmentPhoneNumber) {
	this.departmentPhoneNumber = departmentPhoneNumber;
}

	public String insertNewDepartment()
    {   
		
    	Department department = new Department();
    	department.setName(this.departmentName);
    	department.setCity(this.departmentCity);
    	department.setPhoneNumber(this.departmentPhoneNumber);
    	DepartmentHandler ph = new DepartmentHandler();
    	ph.create(department);
    	return "viewid?faces-redirect=true";
    }
	
	public String getAllDepartments()
	{
		DepartmentHandler ph = new DepartmentHandler();
		departmentList = ph.getAllDepartments();
		return "true";		
	}
	
	public String delete()
	{
		DepartmentHandler ph = new DepartmentHandler();
		ph.deleteByDepartmentName(this.departmentName);
		return "true";
	}
	public String test()
	{
		System.out.println("Test");
		return "failure";
	}
    
 
}
